package com.yeyks.controller.platform;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.common.appcommon.dto.account.AppAccountDTO;
import com.yeyks.common.appcommon.dto.platform.AppMemberCardDTO;
import com.yeyks.common.appcommon.param.platform.QueryMinMemberCardParam;
import com.yeyks.common.appcommon.result.CommonPage;
import com.yeyks.common.appcommon.result.CommonResult;
import com.yeyks.common.utils.apputil.bean.MyBeanUtils;
import com.yeyks.commonReference.service.consumer.MemberCardService;
import com.yeyks.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 会员卡的管理控制类
 * @author: dagny
 * @date: 2019/10/25 0025 15:19
 */
@Api(tags = "AppMemberCardController_优享VIP卡接口", description = "优享VIP会员卡管理【列表查询】")
@RestController
@RequestMapping("/member/card")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppMemberCardController extends BaseController {

    private final MemberCardService memberCardService;

    @ApiOperation("分页查询会员卡列表（兼容V1.8，新增参数salerId）")
    @PostMapping("/list")
    public CommonResult<CommonPage<AppMemberCardDTO>> pageList(@Valid QueryMinMemberCardParam param){

        AppAccountDTO appAccountDTO = this.validToken(param.getToken(), param.getVersion(), param.getPlatform());

        return memberCardService.pageMinVipList(param, MyBeanUtils.convert(appAccountDTO, AccountInfo.class));
    }

}
